import ExtTransform from 'ol-ext/interaction/Transform';
import { setImage } from './addImage';

export function createTransform(amap, layers) {
  const transform = new ExtTransform({
    enableRotatedTransform: false,
    hitTolerance: 1,
    translate: true, // 拖拽
    stretch: false, // 拉伸
    scale: true, // 缩放
    rotate: true, // 旋转
    translateFeature: true,
    noFlip: true,
    layers: [layers]
  });

  transform.on(['select'], function(e) {
    console.log('[获取 e.feature.getGeometry().extent_ 去设置图片的位置]');
    console.log(e.feature.get('adcode'), e.feature.getGeometry().extent_);
  });

  amap.addInteraction(transform);
}
